﻿using System;

using log4net;

using VSTalk.Engine.Core.Disco.Caps;
using VSTalk.Engine.Core.EntitySession;
using VSTalk.Logger;

namespace VSTalk.Engine.Core.Disco
{
    public class DiscoService : IDiscoService, IDisposable
    {
        private static readonly ILog _log = LoggerFactory.Create<DiscoService>();

        private readonly CapsService _capsService;
        
        public DiscoService()
        {
            _log.Info("Initializing " + typeof(DiscoService).FullName);

            _capsService = new CapsService();

            _capsService.StartListen();            
            
            _log.Info("Initialized " + typeof(DiscoService).FullName);
        }

        public bool HasFeature(IInterlocutorResource jid, string uri)
        {
            return _capsService.HasFeature(jid, uri);
        }

        public void Dispose()
        {
            _capsService.StopListen();
        }
    }
}